package com.feeyin.radar.crm.controller;

import com.feeyin.radar.msg.service.InternalMailboxService;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class HintController extends MultiActionController
{
  private InternalMailboxService internalMailboxService;

  public InternalMailboxService getInternalMailboxService()
  {
    return this.internalMailboxService;
  }

  public void setInternalMailboxService(InternalMailboxService internalMailboxService)
  {
    this.internalMailboxService = internalMailboxService;
  }

  public ModelAndView display(HttpServletRequest request, HttpServletResponse response)
  {
    Integer userId = (Integer)request.getSession().getAttribute("userId");
    Integer num = this.internalMailboxService.getNoReadInternalMailCount(userId);
    response.setContentType("text/xml");
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("Expires", 0L);
    try {
      if (num.intValue() != 0)
        response.getWriter().write("<msg>你有" + num + "条新信息</msg>");
      else
        response.getWriter().write("11");
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
    return new ModelAndView("");
  }
}